//
//  FQFillInfoTipView.swift
//  SwiftProject
//
//  Created by 董駸 on 2022/9/5.
//

import UIKit

class FQFillInfoTipView: UIView {

    var buttonBlock : ((_ tag : Int)->Void)?
    
    convenience init() {
        self.init(frame: CGRect(x: 0, y: 0, width: 271, height: 199))
        
        clipsToBounds = true
        backgroundColor = .white
        layer.cornerRadius = 15
        
        let titleLb = QMUILabel(font: .mSFont(18), textColor: .color51)
        titleLb.text = "温馨提示"
        addSubview(titleLb)
        
        titleLb.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(26)
        }
        
        let detailLb = QMUILabel(font: .rSFont(14), textColor: .color51)
        detailLb.text = "提交完资料就知道多少额度了！真的放弃吗？"
        detailLb.numberOfLines = 0
        addSubview(detailLb)
        
        detailLb.snp.makeConstraints { make in
            make.right.equalTo(-22)
            make.left.equalTo(22)
            make.top.equalTo(titleLb.snp.bottom).offset(25)
        }
        
        let rightBtn = QMUIFillButton(fill: .colorMain, titleTextColor: .white)
        rightBtn.setTitle("再想想", for: .normal)
        rightBtn.addTarget(self, action: #selector(buttonClick(_:)), for: .touchUpInside)
        rightBtn.tag = 1
        rightBtn.titleLabel?.font = .mSFont(16)
        rightBtn.clipsToBounds = true
        rightBtn.layer.cornerRadius = 18
        addSubview(rightBtn)
        
        rightBtn.snp.makeConstraints { make in
            make.right.equalTo(-24)
            make.size.equalTo(CGSize(width: 102, height: 36))
            make.bottom.equalTo(-24)
        }
        
        let leftBtn = QMUIGhostButton(ghostColor: .colorMain)
        leftBtn.borderWidth = 0
        leftBtn.setTitle("残忍放弃", for: .normal)
        leftBtn.addTarget(self, action: #selector(buttonClick(_:)), for: .touchUpInside)
        leftBtn.tag = 2
        leftBtn.titleLabel?.font = .mSFont(16)
        leftBtn.clipsToBounds = true
        leftBtn.layer.cornerRadius = 18
        addSubview(leftBtn)
        
        leftBtn.snp.makeConstraints { make in
            make.left.equalTo(24)
            make.size.equalTo(CGSize(width: 102, height: 36))
            make.bottom.equalTo(-24)
        }
    }

    @objc func buttonClick(_ button : QMUIButton) {
        if buttonBlock != nil {
            buttonBlock!(button.tag)
        }
    }
}
